1 #region Using Statements
3 using System.Collections.Generic;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.Graphics;
7 using Microsoft.Xna.Framework.Input;
8 using Microsoft.Xna.Framework.Storage;
9 using Microsoft.Xna.Framework.GamerServices;
13 namespace SuperPolarity
16 /// This is the main type for your game
18 public class SuperPolarity : Game
20 public static GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
23 public SuperPolarity()
26 SuperPolarity.graphics = new GraphicsDeviceManager(this);
27 SuperPolarity.graphics.PreferMultiSampling = true;
28 Content.RootDirectory = "Content";
29 ActorFactory.SetGame(this);
33 /// Allows the game to perform any initialization it needs to before starting to run.
34 /// This is where it can query for any required services and load any non-graphic
35 /// related content. Calling base.Initialize will enumerate through any components
36 /// and initialize them as well.
38 protected override void Initialize()
42 InputController.RegisterEventForButton("changePolarity", Buttons.A);
43 InputController.RegisterEventForKey("changePolarity", Keys.Z);
45 InputController.RegisterEventForButton("shoot", Buttons.X);
46 InputController.RegisterEventForKey("shoot", Keys.X);
50 /// LoadContent will be called once per game and is the place to load
51 /// all of your content.
53 protected override void LoadContent()
55 // Create a new SpriteBatch, which can be used to draw textures.
56 spriteBatch = new SpriteBatch(GraphicsDevice);
58 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
60 ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200));
61 ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200));
62 ActorFactory.CreateMainShip(playerPosition);
66 /// UnloadContent will be called once per game and is the place to unload
69 protected override void UnloadContent()
71 // TODO: Unload any non ContentManager content here
75 /// Allows the game to run logic such as updating the world,
76 /// checking for collisions, gathering input, and playing audio.
78 /// <param name="gameTime">Provides a snapshot of timing values.</param>
79 protected override void Update(GameTime gameTime)
81 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
84 // TODO: Add your update logic here
86 InputController.UpdateInput();
87 ActorManager.Update(gameTime);
89 base.Update(gameTime);
93 /// This is called when the game should draw itself.
95 /// <param name="gameTime">Provides a snapshot of timing values.</param>
96 protected override void Draw(GameTime gameTime)
98 GraphicsDevice.Clear(Color.White);
102 ActorManager.Draw(spriteBatch);